<script setup>
import { ref } from 'vue'
import { ElInput, ElButton } from 'element-plus'
import 'element-plus/dist/index.css'
import axios from 'axios'

const chat = ref('')
const result = ref('')

const sendChat = async () => {
  const response = await axios.get(`/api/ai/generate`, { 
    params: { 
      message: chat.value 
    }
  })
  result.value = response.data
}
</script>

<template>
  <div class="container">
    <h1>hello world!</h1>
    
    <div class="input-group">
      <el-input v-model="chat" placeholder="输入内容..."></el-input>
      <el-button @click="sendChat">发送</el-button>
    </div>
    
    <div class="output-box">
      {{ result }}
    </div>
    
    <!-- 删除: <button @click="toggleDarkMode">切换到黑夜模式</button> -->
  </div>
</template>

<style scoped>
.container {
  background-color: #f5f7fa;
  min-height: 100vh;
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* 恢复：内容垂直对齐方式 */
  transition: background-color 0.3s ease;
  width: 100%;
}


.input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
  width: 100%;
}

.output-box {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  margin-top: 20px;
  width: 100%;
  max-width: 600px;
  word-wrap: break-word;
  background-color: #fff;
  color: #333;
}

</style>

